<?php 
namespace app\admin\model;
use think\Model;
use traits\model\SoftDelete;

//user表的模型类
class User extends Model{



	//引用SoftDelete,软删除
	protected static $deleteTime = 'delete_time';

	//自动完成字段设置
	protected $auto = ['ip','password','create_time'];

	//protected $update = ['login_ip'];
	//自动获取IP
	protected function setIpAttr(){
		return request()->ip();
	}
	//自动MD5加密
	protected function setPasswordAttr($value){
		return md5($value);
	}

	//更新时间

    protected function setCreateTimeAttr($value){
        return strtotime($value);
    }

    //一对一关联模型
    public function Account(){

        return $this->hasOne('Account','user_id','id');
    }

    //一对多 报单订单模型  用户表-报单表
    public function Withdrawlist(){

        return $this->hasMany('Withdrawlist','User_id','id');
    }
}


 ?>